/*
 * Copyright 2011 The Rusted Roof, LLC.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.proteusframework.platformservice.persistence.messagebean;

import org.proteusframework.core.api.IPlatformDelegate;
import org.proteusframework.core.api.model.INamespace;
import org.proteusframework.platformservice.grammar.*;
import org.proteusframework.platformservice.persistence.api.messagebean.IMessageBeanDescriptor;
import org.proteusframework.platformservice.persistence.api.IMessageBeanManager;
import org.proteusframework.platformservice.persistence.api.IResultSet;
import org.proteusframework.platformservice.persistence.api.messagebean.IMessageBeanDescriptorVisitor;
import org.proteusframework.platformservice.persistence.api.messagebean.IMessageBeanProperty;

import java.util.List;
import java.util.SortedSet;

/**
 * @author Tacoma Four
 */
public final class NullMessageBeanManager implements IMessageBeanManager
{
    private static final String UNSUPPORTED_OP_MSG = "NullMessageBeanRegistrar does not support message store operations";

    @Override
    public SortedSet<IMessageBeanDescriptor> getMessageBeanDescriptors()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public void setGrammarInspectorFactory(IGrammarInspectorFactory factory)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public IGrammarInspector createGrammarInspector(IMessageBeanDescriptor messageBeanDescriptor)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public <T extends IPlatformDelegate> void setPlatformDelegate(IPlatformDelegate delegate, Class<T> delegateInterface)
    {
        // Ignore
    }

    @Override
    public void queueMessageBeanRegistration(IMessageBeanDescriptor messageBeanDescriptor) throws UnsupportedMessageBeanException
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public void processRegistrationQueue()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public boolean isMessageBeanRegistered(IMessageBeanDescriptor messageBeanDescriptor)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public boolean isMessageBeanRegistered(INamespace namespace)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public IMessageBeanDescriptor getMessageBeanDescriptor(INamespace namespace)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public <T> long saveMessage(Class<T> messageBeanClass, T message)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public <T> boolean deleteMessage(Class<T> messageBeanClass, T message)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public <T> List<T> listMessages(Class<T> messageBeanClass)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public <T> boolean updateMessage(Class<T> messageBeanClass, T message, IMessageBeanProperty[] properties)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public boolean supportsUpdates()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public boolean supportsDeletes()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public <T> Iterable<T> createIterator(Class<T> messageBeanClass)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public <T> IResultSet<T> executeQuery(Class<T> messageBeanClass, String query) throws org.proteusframework.platformservice.grammar.IllegalExpressionException
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public <T> IResultSet<T> executeQuery(Class<T> messageBeanClass, String query, Object... params) throws IllegalExpressionException
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public boolean supportsParameterizedQueries()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public boolean supportsExpressionQueries()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public List<String> describeExpressionSupport()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public boolean supportsIndices()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public boolean supportsInterfaces()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public boolean supportsMessageBeanManagement()
    {
        return false;
    }

    @Override
    public List<DataType> describeDataTypeSupport()
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }

    @Override
    public void accept(IMessageBeanDescriptorVisitor visitor)
    {
        throw new IllegalStateException(UNSUPPORTED_OP_MSG);
    }
}
